package com.lightsaber.trade.cloth.service.category;

import java.util.List;

import com.lightsaber.trade.cloth.entity.category.Category;
import com.lightsaber.trade.cloth.entity.category.CategoryBranch;
import com.lightsaber.trade.cloth.entity.category.CategoryLeaf;
import com.lightsaber.trade.cloth.entity.category.CategoryNode;

public interface CategoryNodeService {

    public CategoryNode findById(String id);

    public CategoryBranch findBranchById(String id);

    public CategoryLeaf findLeafById(String id);

    public void deleteById(String id) throws Exception;

    public void validateCategoryNode(CategoryNode categoryNode) throws Exception;
    
    public void saveLeafFromPage(final CategoryLeaf categoryNode) throws Exception;

    //
    // public void deleteLeafNodeById(String id);
    //
    // public void deleteBranchNodeById(String id);

    public CategoryNode findByCategoryId(String categoryId);

    public void saveBranch(CategoryBranch categoryNode) throws Exception;

    public void saveLeaf(CategoryLeaf categoryNode) throws Exception;

    public void saveRoot(CategoryNode categoryNode) throws Exception;

    public void deleteAllNodeExceptRoot(String id);

    public void changeParentNode(String currentNodeId, String parentId) throws Exception;

    /**
     * Example Path： List={'root','node-A','node-A-child1'}
     * 
     * @param categoryNode
     * @return
     */
    public List<String> getTreePathOfNode(CategoryNode categoryNode);

    /**
     * Get the node of the tree which the node must mapping the path <br>
     * Example Path： List={'root','node-A','node-A-child1'}, return the node
     * which name is 'node-A-child1'
     * 
     * @param nodePath
     * @param masterTree
     * @return
     */
    public CategoryNode getNodeByPath(List<String> nodePath, Category masterTree);

    public Category getCategoryByNode(final CategoryNode node);
}
